package com.example.leetdemo.process;

import com.example.leetdemo.utils.DateUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.IntStream;

public class Solution1335 {

    public int minDifficulty(int[] jobDifficulty, int d) {
        if (jobDifficulty.length < d) {
            return -1;
        }
        int[][] dp = new int[jobDifficulty.length + 1][d + 1];
        for (int i = 0; i < jobDifficulty.length; i++) {
            dp[0][i + 1] = Math.max(dp[0][i], jobDifficulty[i]);
        }
        for (int i = 0; i < d; i++) {

        }
        return d;
    }

    public static void main(String[] args) {

//        String begin = "2023-09-18 14:30:44";
//        LocalDateTime beginTime = DateUtils.parse(begin);
//        beginTime = beginTime.plusDays( 1 - beginTime.getDayOfWeek().getValue());
//        System.err.println(beginTime.toString());
//        Short s = (short) 1;
//        String[] arr = new String[] {"1", "2"};
//        System.err.println(arr[s]);
        IntStream.range(0, 10).forEach(i -> System.err.println(i));
        Set<Integer> set = new HashSet<>();
        set.add(1);
        set.remove(1);
        Integer[] a = new Integer[2];
        System.err.println(LocalDateTime.now());

    }

    public int singleNumber(int[] nums) {
        int n = 0;
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < nums.length; i++) {
            map.put(nums[i], map.getOrDefault(nums[i], 0) + 1);
        }
        for (Integer num : map.keySet()) {
            if (map.get(num) == 1) {
                n = num;
                break;
            }
        }
        return n;
    }

    public int maxFrequency(int[] nums, int k) {
        Arrays.sort(nums);
        int n = 1, l = 0, sum = 0, max = 1;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
            if (n * nums[i] <= sum + k) {
                max = Math.max(max, n++);
            } else {
                while (n * nums[i] > k + sum && l <= i + 1) {
                    n = n - 1;
                    sum = sum - nums[l++];
                }
            }
        }
        return max;
    }

    public int[][] insert(int[][] intervals, int[] newInterval) {
        Stack<int[]> stack = new Stack<>();
        boolean merge = false;

        if (intervals[0][0] >= newInterval[0] && intervals[0][0] <= newInterval[1]) {
            intervals[0][0] = newInterval[0];
            merge = true;
        }
        if (intervals[0][1] >= newInterval[0] && intervals[0][1] <= newInterval[1]) {
            intervals[0][1] = newInterval[1];
            merge = true;
        }
        for (int i = 0; i < intervals.length; i++) {
            if (!merge && intervals[i][1] >= newInterval[0]) {
                intervals[i][1] = newInterval[1];
                merge = true;
            }

            stack.add(intervals[i]);
        }
        return null;
    }

}
